<?php
require '../kernel/common.php';

// Recuperation variable
$type = retrieve('GOST','type');
$departement = retrieve('GOST','departement');
$ville = retrieve('GOST','ville');
$secteur = retrieve('GOST','secteur');
$departement = retrieve('GOST','departement');
$prix = retrieve('GOST','prix');
$nb_max = retrieve('GOST','max');
$agence = retrieve('GOST','agence');

$C = array(
'type' =>   $type,
'departement'   =>  $departement,
'ta.ville' =>  addslashes($ville),
'secteur'   =>  $secteur,
'agence'    =>  $agence,
'active'    =>  '1',
'prix'  =>  $prix);

// Construction variable
$Sql = $GLOBALS['db']->query("SELECT * FROM immo_annonce ta ". Annonce::ConstructCondition($C) ." ORDER BY date_ajout DESC LIMIT 30");

$Annonces = $GLOBALS['db']->fetchAll($Sql);

// FICHIER XML
header("Content-Type: text/xml");
echo '<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<channel>
    <title>' . $setting['titre_site'] . '</title>
    <link>' . $config['url'] . '</link>
    <language>fr</language>
    <webMaster>' . $setting['email_contact'] . '</webMaster>';
    
foreach($Annonces as $A):

    echo '
    <item>
        <title>'. parse_simple($A['titre']) .'</title>
        <link>'. $config['url'] .'annonce_detail.php?annonce=' . $A['id'] . '</link>
        <pubDate>' . date("r",$A['date_ajout']) . '</pubDate>
        <description>' . htmlspecialchars($A['description']) . '</description>
    </item>';
    
endforeach;

echo '</channel></rss>';
?>